package com.hm.jiaowuxitong.ui;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class StudentGui {
    public StudentGui() {
        JFrame frame = new JFrame("学生");
        frame.setSize(1200, 700);
        //创建画布
        //创建画布
        JPanel panel = new JPanel(new BorderLayout());
        //创建方向布局
        SpringLayout layout = new SpringLayout();
        panel.setLayout(layout);
        JButton button1 = new JButton("查询成绩");
        layout.putConstraint(SpringLayout.WEST, button1, 150, SpringLayout.WEST, panel);
        layout.putConstraint(SpringLayout.NORTH, button1, 70, SpringLayout.NORTH, panel);
        button1.setFont(new Font(" ", 2, 20));
        JButton button2 = new JButton("查询课表");
        layout.putConstraint(SpringLayout.WEST, button2, 150, SpringLayout.WEST, panel);
        layout.putConstraint(SpringLayout.NORTH, button2, 150, SpringLayout.NORTH, panel);
        button2.setFont(new Font(" ", 2, 20));
        JButton button3 = new JButton("查询信息");
        layout.putConstraint(SpringLayout.WEST, button3, 150, SpringLayout.WEST, panel);
        layout.putConstraint(SpringLayout.NORTH, button3, 230, SpringLayout.NORTH, panel);
        button3.setFont(new Font(" ", 2, 20));
        JButton button5 = new JButton("查询信息");
        layout.putConstraint(SpringLayout.WEST, button3, 150, SpringLayout.WEST, panel);
        layout.putConstraint(SpringLayout.NORTH, button3, 310, SpringLayout.NORTH, panel);
        button3.setFont(new Font(" ", 2, 20));
        JButton button4 = new JButton("退出登录");
        layout.putConstraint(SpringLayout.WEST, button4, 200, SpringLayout.WEST, panel);
        layout.putConstraint(SpringLayout.NORTH, button4, 380, SpringLayout.NORTH, panel);
        button4.setFont(new Font(" ", 2, 20));



        // 创建标题标签
        JLabel label = new JLabel("通知栏");
        label.setForeground(new Color(226,17,17));
        Font font = new Font(label.getFont().getName(), Font.PLAIN, 30);
        label.setFont(font);
        JTextField textField = new JTextField();
        textField.setEditable(false);
        layout.putConstraint(SpringLayout.EAST,textField,-30,SpringLayout.EAST,panel);
        layout.putConstraint(SpringLayout.NORTH,textField,80,SpringLayout.NORTH,panel);
        layout.putConstraint(SpringLayout.NORTH,label,5,SpringLayout.NORTH,panel);
        layout.putConstraint(SpringLayout.EAST,label,-40,SpringLayout.EAST,panel);
        textField.setFont(new Font("", 2, 40));
        textField.setPreferredSize(new Dimension(300,300));
        label.setPreferredSize(new Dimension(200,80));
        panel.add(label);
        panel.add(textField);

        JLabel img = new JLabel();
        ImageIcon imageIcon = new ImageIcon("image/4.jpg");  // 将"path/to/your/image.jpg"替换为你的图片路径
        img.setIcon(imageIcon);

        panel.add(button1);
        panel.add(button2);
        panel.add(button3);
        panel.add(button4);
        panel.add(button5);

        panel.add(img);
        button1.setBorderPainted(false);//不显示按钮的边框。
        button1.setRolloverEnabled(true);//启用按钮悬停效果。
        button2.setBorderPainted(false);//不显示按钮的边框。
        button2.setRolloverEnabled(true);//启用按钮悬停效果。
        button3.setBorderPainted(false);//不显示按钮的边框。
        button3.setRolloverEnabled(true);//启用按钮悬停效果。
        button4.setBorderPainted(false);//不显示按钮的边框。
        button4.setRolloverEnabled(true);//启用按钮悬停效果。
        button5.setBorderPainted(false);//不显示按钮的边框。
        button5.setRolloverEnabled(true);//启用按钮悬停效果。

        //把画布添加至面板
        frame.setContentPane(panel);
        //禁止面板放大缩小
        frame.setResizable(false);
        //允许关闭整个应用
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        //将面板显示
        frame.setVisible(true);
        // 设置窗口居中显示
        frame.setLocationRelativeTo(null);
        // 显示窗口
        frame.setVisible(true);
        //添加点击事件
        button1.addMouseListener(new MouseListener() {
            @Override
            public void mouseClicked(MouseEvent e) {

            }

            @Override
            public void mousePressed(MouseEvent e) {
                new ShowStudentGradeButton();
                frame.dispose();

            }

            @Override
            public void mouseReleased(MouseEvent e) {

            }

            @Override
            public void mouseEntered(MouseEvent e) {

            }

            @Override
            public void mouseExited(MouseEvent e) {

            }
        });
        button2.addMouseListener(new MouseListener() {//学生查询课表
            @Override
            public void mouseClicked(MouseEvent e) {

            }

            @Override
            public void mousePressed(MouseEvent e) {
                new StudentCourseInfoUI();
                frame.dispose();

            }

            @Override
            public void mouseReleased(MouseEvent e) {

            }

            @Override
            public void mouseEntered(MouseEvent e) {

            }

            @Override
            public void mouseExited(MouseEvent e) {

            }
        });
        button3.addMouseListener(new MouseListener() {
            @Override
            public void mouseClicked(MouseEvent e) {

            }

            @Override
            public void mousePressed(MouseEvent e) {
                new ShowSelfStudentButtom();
                frame.dispose();
            }

            @Override
            public void mouseReleased(MouseEvent e) {

            }

            @Override
            public void mouseEntered(MouseEvent e) {

            }

            @Override
            public void mouseExited(MouseEvent e) {

            }
        });
        button4.addMouseListener(new MouseListener() {
            @Override
            public void mouseClicked(MouseEvent e) {

            }

            @Override
            public void mousePressed(MouseEvent e) {
                new GifTest();
                frame.dispose();

            }

            @Override
            public void mouseReleased(MouseEvent e) {

            }

            @Override
            public void mouseEntered(MouseEvent e) {

            }

            @Override
            public void mouseExited(MouseEvent e) {

            }
        });
        button4.addMouseListener(new MouseListener() {
            @Override
            public void mouseClicked(MouseEvent e) {

            }

            @Override
            public void mousePressed(MouseEvent e) {
                new GifTest();
                frame.dispose();

            }

            @Override
            public void mouseReleased(MouseEvent e) {

            }

            @Override
            public void mouseEntered(MouseEvent e) {

            }

            @Override
            public void mouseExited(MouseEvent e) {

            }
        });
        button4.addMouseListener(new MouseListener() {
            @Override
            public void mouseClicked(MouseEvent e) {

            }

            @Override
            public void mousePressed(MouseEvent e) {
                new ChangeStudentPassword();
                frame.dispose();

            }

            @Override
            public void mouseReleased(MouseEvent e) {

            }

            @Override
            public void mouseEntered(MouseEvent e) {

            }

            @Override
            public void mouseExited(MouseEvent e) {

            }
        });
    }


    public static void main(String[] args) {
        new StudentGui();
    }
}